package org.jeecg.modules.solitaire_app.app.controller;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.solitaire_app.app.entity.YsyUsers;
import org.jeecg.modules.solitaire_app.app.query.UsersLoginQuery;
import org.jeecg.modules.solitaire_app.app.query.UsersPhoneQuery;
import org.jeecg.modules.solitaire_app.app.service.WXLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Description: 微信登录
 * @Author: 杨荣森
 * @Date: 2021-08-25
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "微信登录")
@RestController
@RequestMapping("/app/sys")
public class WXLoginController {

    @Autowired
    private WXLoginService wxLoginService;

    /**
     * 微信登录-微信登录
     * @return
     */
    @ApiOperation(value = "微信登录-微信登录", notes = "微信登录-微信登录")
    @PostMapping(value = "/wechatLogin")
    public Result<YsyUsers> wechatLogin(@RequestBody UsersLoginQuery cpsUsersAO){
        return wxLoginService.webchatLogin(cpsUsersAO);
    }

    /**
     * 微信登录-查询用户信息
     * @return
     */
    @ApiOperation(value = "微信登录-查询用户信息", notes = "微信登录-查询用户信息")
    @GetMapping(value = "/getCpsUsersByOpenId/openId/{openId}")
    public Result<YsyUsers> getCpsUsersByOpenId(@PathVariable("openId") String openId){
        return wxLoginService.getCpsUsersByOpenId(openId);
    }

    /**
     * 微信登录-修改用户信息
     * @return
     */
    @ApiOperation(value = "微信登录-修改用户信息", notes = "微信登录-修改用户信息")
    @PostMapping(value = "/updateUser")
    public Result<?> updateUser(@RequestBody YsyUsers saUsers){
        return wxLoginService.updateUser(saUsers);
    }

    /**
     * 微信登录-获取用户手机号
     * @return
     */
    @ApiOperation(value = "微信登录-获取用户手机号", notes = "微信登录-获取用户手机号")
    @PostMapping(value = "/getUserPhone")
    public Result<YsyUsers> getUserPhone(@RequestBody UsersPhoneQuery usersPhoneQuery){
        return wxLoginService.getUserPhone(usersPhoneQuery);
    }

    /**
     * 微信登录-用户列表
     * @return
     */
    @ApiOperation(value = "微信登录-用户列表", notes = "微信登录-用户列表")
    @PostMapping(value = "/getUserList")
    public Result<PageInfo<YsyUsers>> getUserList(@RequestBody Map<String,Object> map){
        return wxLoginService.getUserList(map);
    }

}
